home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: Is there a standard for * and & placement style?
- Message-ID: <marnoldDnJ2xz.KsM@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com> <4gckd5$bc7@clarknet.clark.net> <marnoldDn63vB.H6n@netcom.com> <4gk1b8$mtm@werple.net.au> <marnoldDn9u0A.GAD@netcom.com> <4gumu0$7c9@werple.net.au>
- Date: Thu, 29 Feb 1996 08:15:35 GMT
- Sender: marnold@netcom23.netcom.com
-
- davidw@werple.net.au (David White) writes:
-
- >marnold@netcom.com (Matt Arnold) writes:
-
-
- >>...is a "special case" for the "char *"-style, simply highlights that the
- >>style, IMO, is conceptually inconsistent. Certainly, the function itself
- >>doens't have pointer-ness (although, as for as the language it concerned, it
- >>resovles to an expression that does) and so it doesn't seem quite right to
- >>associate the * with the function name. It seems inconsistent that you
- >>would make this concession, but turn around and insist the "char *p" makes
- >>sense for the declaration of p.
-
- >It wasn't a concession. I would use 'char *foo()'. I was just saying that
- >I can understand why some people prefer 'char* foo()' (and 'char* p').
-
- I see.
-
- >I don't want to drag this on, because it doesn't bother me if others use
- >the 'char* p' form, but I don't think my point came across too well.
- >My main point concerned you and another poster suggesting that the form:
- > char* p, q;
- >should declare both 'p' and 'q' to be char*. I
-
- I didn't suggest that. I pointed out that I personally never use that
- form because I find it visually inconsistent and potentially bug-prone
- (for me anyway).
-
- I suppose it follows that I never use mutliple code statements on a
- single line, delimited by commas, either. Yuck!
-
- > was just trying to demonstrate
- >that, without making special rules for '*' (and '&'), this doesn't fit in
- >with the language. As far as the compiler is concerned, *, &, [],
- >() are operators that apply to an operand. In its parsing, it treats
- >them that way whether it is an expression or a declaration. It is only
- >because '*' happens to be a pre-operand operator that you are able
- >to place the '*' with the 'char'. That's why I prefer the 'char *p'
- >(and 'char *foo()') form; I just follow the same rules as the compiler
- >for everything. I don't see any fundamental difference between
- >'array of char' and 'pointer to char'; arrays and pointers are both
- >types derived from some other, but you can't write 'char[10] p', simply
- >because thej[10] is on the wrong side of 'p'.
-
- Well, as I said before, this is one of those preference things, just like
- where curly braces should go.
-
- I still think it makes more sense to think of declaration statements as
- types and instances of those types. In a declaration, I'd rather see *
- as an operator on the type rather than on the instance. Because the
- "loose" multiple-instance per type declaration rules interfere with this
- view, I never use that form.
-
- Regards,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-